package net.homelinux.chaoswg.io.renga.core.gui.operations.visualisations;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;

import org.jdom.Element;

public class SplitBlockVisualisation extends BlockVisualisation {
    protected Color inner = null;
    protected int split = 0;
    
    public SplitBlockVisualisation (final int split) {
        super ();
        this.split = split;
    }
    
    public SplitBlockVisualisation (final int x, final int y, final int width, final int heigth, final int split) {
        super (x,y,width,heigth);
        this.split = split;
    }
    
    public SplitBlockVisualisation (final Point position, final int width, final int height, final int split) {
        super (position, width, height);
        this.split = split;
    }

    public SplitBlockVisualisation (final Rectangle rect, final int split) {
        super (rect);
        this.split = split;
    }
    
    public void draw (final Graphics g) {
        super.draw (g);
        final int splitdistance = this.area.width / split;
        
        for (int i = 1; i < split; ++i) {
            g.fillRect(this.area.x - 2 + i * splitdistance, this.area.y, 4, this.area.height);
        }
    }
    
    public Element writeYourself () {
        Element toReturn = super.writeYourself();
        Element splitElement = new Element ("split");
        splitElement.setText(split + "");
        
        toReturn.addContent(splitElement);
        
        
        return toReturn;
    }
}
